﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>

</head>
<body>
    <input type="text" name="abc" id="abc"/>
    <input type="text" name="abc"   />
    <input type="text" name="abc" />

<script type="text/javascript">
    function get(el) {
        var id, nodes, c, i, len, attr, ret = null;

        if (el) {
            if (typeof el == 'string' || typeof el == 'number') { // id
                id = el + '';
                el = document.getElementById(el);
                attr = (el) ? el.attributes : null;
                if (el && attr && attr.id && attr.id.value === id) { // IE: avoid false match on "name" attribute
                    return el;
                } else if (el && document.all) { // filter by name
                    el = null;
                    nodes = document.all[id];
                    if (nodes && nodes.length) {
                        for (i = 0, len = nodes.length; i < len; ++i) {
                            if (nodes[i].id === id) {
                                return nodes[i];
                            }
                        }
                    }
                }
            } else if (!el.nodeType && 'length' in el) { // array-like 
                c = [];
                for (i = 0, len = el.length; i < len; ++i) {
                    c[c.length] = get(el[i]);
                }

                el = c;
            }

            ret = el;
        }

        return ret;
    }

    var GET_COMPUTED_STYLE = 'getComputedStyle', OWNER_DOCUMENT = 'ownerDocument',
        DEFAULT_VIEW = 'defaultView',
        DOCUMENT_ELEMENT = 'documentElement', CURRENT_STYLE = 'currentStyle';
    
    function getComputedStyle(el, property) {
        if (window[GET_COMPUTED_STYLE]) {
            return el[OWNER_DOCUMENT][DEFAULT_VIEW][GET_COMPUTED_STYLE](el, null)[property];
        }
    }

    alert(getComputedStyle(get("abc"),"name"));
</script>
</body>
</html>
